home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2008 September
/
PCWorld_2008-09_cd.bin
/
multimedia
/
tuxpaint
/
tuxpaint-0.9.20-win32-installer.exe
/
{app}
/
docs
/
zh_tw
/
mkTuxpaintIM.py
< prev
next >
Wrap
Text File
|
2008-07-01
|
2KB
|
47 lines
#!/usr/bin/env python
# -*- coding: Big5 -*-
# Copyright: Song Huang <songhuang.tw@gmail.com>
# create: 2007/11/04
# License: GNU GPL
ver = "0.1"
from optparse import OptionParser
from codecs import open as copen
if __name__ == '__main__':
# parse script arguments
optparser = OptionParser(usage='./%prog [options]', version="%prog "+ver)
optparser.add_option("-o", "--outputfile", action="store",
help=unicode("┐ΘÑX└╔«╫¬║ªW║┘","big5"))
optparser.add_option("-m", "--phonemap", action="store",
help=unicode("ñññσ╗P¬`¡╡╣∩╖╙¬φ(utf8 - expect file was xcin table:phone.cin)","big5"))
(options, args) = optparser.parse_args()
## │]⌐wÑD¡n┼▄╝╞
# ┐ΘÑX└╔ªW
outfile = copen(options.outputfile, "w", "utf8")
outfile.write("section\n\n")
# ñññσ╗P¬`¡╡╣∩╖╙¬φ
phonemap = options.phonemap
# ░⌡ªµ┐ΘÑX
cinfile = copen(phonemap, "r", "utf8")
(bopomofo, chinachar) = cinfile.readline().split()
bpmf_count = 0
bpmf_temp = bopomofo
while bopomofo:
if bpmf_temp == bopomofo:
bpmf_count += 1
else:
bpmf_count = 1
bpmf_temp = bopomofo
chinacharnum = str(hex(ord(chinachar)))[2:]
outfile.write("%s\t%s%s\t-\t# %s \n" % (chinacharnum, bopomofo, bpmf_count, chinachar))
try:
(bopomofo, chinachar) = cinfile.readline().split()
except:
break
# ╡▓º⌠
cinfile.close()
outfile.close()